import axios from "axios";

// 单例模式
class Config {
  static instance = new Config(); //js是单线程的，不用考虑线程安全问题
  interfaceBase;
  web4;
  constructor() {
    this.interfaceBase = location.protocol + "//" + location.host;
  }

  loadConfig() {
    return axios
      .get("/ConfCenter/web5/config.json")
      .then((axios) => {
        Object.assign(Config.instance,axios.data);
        return Config.instance
      })
      .catch((error) => {
        if(error.toString().indexOf("404")) error="未找到/confCenter/config.json"
        throw "获取网站配置失败：" + error
      });
  }
}
export default Config.instance;


